package com.youge.rabbitmqspringboot.topic;

import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @author: hcf
 * @qq: 46914685
 * @email: 46914685@qq.com
 * @date: 2020-10-08 22:45
 */
@Component
public class TopicCustomer {


    @RabbitListener(bindings = {
            @QueueBinding(
                    value = @Queue("topic_queue"),
                    exchange = @Exchange(value ="topic_exchange" ,type = "topic"),
                    key = {"user.save","user.*"}
            )
    })
    public void recevice1(String message) {
        System.out.println("message1 = " + message);
    }

    @RabbitListener(bindings = {
            @QueueBinding(
                    value = @Queue,
                    exchange = @Exchange(value ="topic_exchange" ,type = "topic"),
                    key = {"order.#","product.#","user.*"}
            )
    })
    public void recevice2(String message) {
        System.out.println("message2 = " + message);
    }
}
